home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-20 / chart1.zip / CHART12.C < prev   
C/C++ Source or Header  |  1991-03-12  |  3KB  |  101 lines

  1. /*
  2.  *    chart.c, Version 1.2
  3.  *
  4.  *    This program builds a chart suitable for scanner frequency
  5.  *    entries.  The frequency is shown with an area for a short
  6.  *    note about each frequency.  Start with a frequency such as
  7.  *    144, 154, etc.
  8.  *
  9.  *    ###    This little program is for VHF and UHF
  10.  *    @@@    It is not designed for less than 1 MHz
  11.  *    !!!    or higher than 999 MHz.
  12.  *
  13.  *    ###    Also, the program ALWAYS prints a full
  14.  *    @@@    page.  It may stop on a frequency greater
  15.  *    !!!    than the stop setting, given wierd numbers.
  16.  *
  17.  *    The chart is output to the screen, printer, or file:
  18.  *
  19.  *        chart 5 144 149            -    Screen
  20.  *        chart 12.5 144 149 twometer    -    File
  21.  *        chart 25 144 149 prn        -    Printer
  22.  *
  23.  *    Based on a program by Tony B. Anderson, Copyright (c) 1987
  24.  *            All Rights Reserved
  25.  *
  26.  *    Turbo-C Version written by Steve Sampson 75136,626
  27.  *
  28.  *    1.0    Converted Tony's BASIC and expanded a little.
  29.  *    1.1    Fixed the frequencies so they are right justified instead
  30.  *        of left.
  31.  *    1.2    Made the frequency spacing programmable.
  32.  */
  33.  
  34. #include <stdio.h>
  35. #include <math.h>
  36.  
  37. static char    top[] = "          ________ ";
  38. static char    bot[] = "|________|";
  39. static double    s1, s2, s3;
  40.  
  41.  
  42. void
  43. main(argc, argv)
  44. int        argc;
  45. register char    *argv[];
  46. {
  47.     register int    i;
  48.  
  49.     if (argc < 4 || argc > 5)  {
  50.         fprintf(stderr, "Usage: chart 'kHz spacing' 'start freq' 'stop freq' [filename | PRN]\n");
  51.         exit(1);
  52.     }
  53.  
  54.     s1 = atof(argv[1]) / 1000.0000;
  55.     s2 = atof(argv[2]);
  56.     s3 = atof(argv[3]);
  57.  
  58.     if (s1 > .99990)  {
  59.         fprintf(stderr, "Fatal - Spacing limits are 1 kHz to 999.9 kHz\n");
  60.         exit(1);
  61.     }
  62.  
  63.     if ((s2 < 1.0) || (s3 > 999.0))  {
  64.         fprintf(stderr, "Fatal - Start/Stop limits are 1 MHz to 999 MHz\n");
  65.         exit(1);
  66.     }
  67.  
  68.     if (s3 < s2)  {
  69.         fprintf(stderr, "Fatal - Start frequency greater than Stop\n");
  70.         exit(1);
  71.     }
  72.  
  73.     if (argc == 5)  {
  74.         if (freopen(argv[4], "w", stdout) == NULL)  {
  75.             fprintf(stderr, "Fatal - Unable to open output file\n");
  76.             exit(1);
  77.         }
  78.     }
  79.  
  80.     do  {
  81.         printf("\t\tS C A N N E R   F R E Q U E N C Y   C H A R T\n");
  82.         printf("\t\t---------------------------------------------\n\n");
  83.         printf("%s %s %s %s\n", top, top, top, top);
  84.  
  85.         for (i = 0; i < 50; i++, s2 += s1)
  86.             printf("%8.4f %s %8.4f %s %8.4f %s %8.4f %s\n",
  87.                  s2, bot,
  88.                  s2 + (s1 *  50.0000), bot,
  89.                  s2 + (s1 * 100.0000), bot,
  90.                  s2 + (s1 * 150.0000), bot
  91.             );
  92.  
  93.         putchar('\014');    /* form feed */
  94.  
  95.     } while (((s2 += (s1 * 150.0000)) + s1) < s3);
  96.  
  97.     exit(0);
  98. }
  99.  
  100. /* EOF */
  101.